package edu.sctu.zhengsenwen.month201506.day20150615.txt;

import java.io.*;


/**
 * Created by user15 on 2015/6/15.
 */
public class TxtFileLineReadOrWrite {

    public TxtFileLineReadOrWrite() throws IOException {

        File inFile = new File("C:\\C20\\demo1.txt");


        FileReader reader = new FileReader(inFile);
        BufferedReader bufferedReader = new BufferedReader(reader);


        FileWriter writer = new FileWriter("C:\\C20\\demo3.txt");

        BufferedWriter bufferedWriter = new BufferedWriter(writer);

        //判断是否到达末尾
        while (bufferedReader.ready()) {

            String inString = bufferedReader.readLine();

            System.out.println("行的内容 = " + inString);

            //写出字符串
            bufferedWriter.write(inString);

            bufferedWriter.newLine();
        }

        bufferedReader.close();
        bufferedWriter.close();
        System.out.println("成功创建demo3.txt文件");

    }

    public static void main(String[] args) {


        try {
            new TxtFileLineReadOrWrite();

        } catch (Exception ex) {
        }
    }
}
